let recommen = document.querySelector("#recommen");
let ul = document.querySelector("#recommen>ul");
let lis = document.querySelectorAll("#recommen>ul li");
fetch("http://chst.vip:1234/api/getmoneyctrl")
    .then(body => body.json())
    .then(res => {
        console.log(res);
        let html = "";
        res.result.forEach(item => {
            html += `
                <li productid=${item.productId}>
                    ${item.productImgSm}
                    <div>
                    <span>${item.productName}<span>${item.productPinkage}</span></span><br><br><br><span>${item.productFrom}</span><span>|</span><span>${item.productTime}</span>
                    <span>${item.productComCount}</span>
                    </div>
                </li>
                `
        })
        ul.innerHTML = html;
        console.log(res);
        let lis = document.querySelectorAll('#recommen li');
        console.log(lis);
        [...lis].forEach(li => {
            li.onclick = function() {
                let productid = this.getAttribute("productid")
                    //点击的时候要跳转到详情页
                location.href = "./discount.html?productid=" + productid
            }
        })
    })

//更多菜单
let more = document.querySelector("#more")
let uu = document.querySelector("#menu ul")
let menu = document.querySelector("#menu")
console.log(menu);

// function stopDefault(e) {
//     if (e && e.preventDefault)
//         e.preventDefault();
//     else
//         window.event.returnValue = false;
// }

let uh = uu.style.height;
let mh = menu.style.height;
let flag = true;
more.onclick = function(e) {
    // stopDefault(e);
    if (flag) {
        uu.style.height = 5.3333 + 'rem';
        menu.style.height = 5.3333 + 'rem';
        flag = false;
    } else {
        uu.style.height = 8.26666 + 'rem'
        menu.style.height = 8.26666 + 'rem'
        flag = true;
    }
}